//
//  LcLoadMoreView.m
//  18Birdies
//
//  Created by Lc on 15/4/23.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import "LcFont.h"
#import "LcLoadMoreView.h"
#import "LcUIUtility.h"
#import "UIColor+Lc.h"

@interface LcLoadMoreView ()
@property(nonatomic, weak) UIActivityIndicatorView* progressView;
@end

@implementation LcLoadMoreView

- (instancetype)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    self.backgroundColor = LC_COLOR_WHITE;
    UIActivityIndicatorView* progressView = [[UIActivityIndicatorView alloc]
        initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    progressView.center = self.center;
    [progressView startAnimating];
    [self addSubview:progressView];
    self.progressView = progressView;
  }
  return self;
}

+ (LcLoadMoreView*)loadMoreView {
  LcLoadMoreView* loadMoreView = [[self alloc]
      initWithFrame:CGRectMake(0, 0, [LcUIUtility screenWidth], 44)];
  loadMoreView.backgroundColor =[UIColor clearColor];
  return loadMoreView;
}

- (void)triggerShow {
  if (!self.isLoading && self.delegate != nil) {
    [self.delegate onLoadMore:self];
  }
}

@end
